package 华为.text02_计算某字符出现次数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String string = br.readLine();
        // 读取一行字符
        Scanner scanner = new Scanner(System.in);
        // 读取输入的单个字符
        String s = scanner.nextLine();
       // 将 string 类型转 char 类型
        char c = s.charAt(0);
        // 获取按空格切割后的字符串数组
        String[] result = string.split(" ");
        int num=0;
        for (String s1 : result) {
            for (int i = 0; i < s1.length(); i++) {
                // 如果是数字
                if (c>=0&&c<=9){
                    if (c==s1.charAt(i)){
                        num++;
                    }
                    // 如果是小写字母
                }else if (c>='a'&&c<='z'){
                    if (c==s1.charAt(i)||(c-32)==s1.charAt(i)){
                        num++;
                    }
                }else {
                    // 如果是大写字母
                    if (c==s1.charAt(i)||(c+32)==s1.charAt(i)){
                        num++;
                    }
                }
            }
        }

        System.out.println(num);
    }
}